package cn.getech.data.development.controller.api;

import cn.getech.data.development.api.ConfConnectApi;
import cn.getech.data.development.entity.ConfConnect;
import cn.getech.data.development.service.ConfConnectApiService;
import cn.getech.data.development.service.ConfConnectService;
import cn.getech.data.development.vo.ConfConnectApiVo;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ConfConnectApiController
 * @Description TODO
 * @Author Getech
 * @Date 2020/12/24 11:46
 */
@RestController
public class ConfConnectApiController implements ConfConnectApi {

    @Autowired
    private ConfConnectApiService confConnectApiService;

    @Autowired
    private ConfConnectService confConnectService;

    @Override
    public List<ConfConnectApiVo> getAuthConfConnectList() {
        //获取有权限的数据库连接
        List<ConfConnectApiVo> authConfList=confConnectApiService.queryAuthConfList();
        return  authConfList;
    }

    @Override
    public ConfConnectApiVo getConnectById(Integer connectId) {
        // 获取数据库连接
        ConfConnectApiVo confConnectApiVo=new ConfConnectApiVo();
        ConfConnect confConnect= confConnectService.getById(connectId);
        BeanUtil.copyProperties(confConnect,confConnectApiVo);
        return confConnectApiVo;
    }
}
